package com.repair.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.repair.entity.RepairmanOrder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;

@Mapper
public interface RepairmanOrderMapper extends BaseMapper<RepairmanOrder> {
    
    @Select("SELECT ro.*, r.title, r.description, r.status as orderStatus, " +
            "u.username as userUsername, u.real_name as userReaName, u.phone as userPhone " +
            "FROM repairman_order ro " +
            "LEFT JOIN repair_order r ON ro.order_id = r.id " +
            "LEFT JOIN user u ON r.user_id = u.id " +
            "WHERE ro.repairman_id = #{repairmanId} " +
            "ORDER BY ro.create_time DESC")
    List<RepairmanOrder> getRepairmanOrders(Long repairmanId);
    
    @Select("SELECT ro.*, r.title, r.description, r.status as orderStatus, " +
            "u.username as userUsername, u.real_name as userRealName, u.phone as userPhone " +
            "FROM repairman_order ro " +
            "LEFT JOIN repair_order r ON ro.order_id = r.id " +
            "LEFT JOIN user u ON r.user_id = u.id " +
            "WHERE ro.order_id = #{orderId}")
    RepairmanOrder getOrderDetail(Long orderId);
} 